package com.cskaoyan.shiro;

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;

public class CustomWebSessionManager extends DefaultWebSessionManager {
    @Override
    protected Serializable getSessionId(ServletRequest req, ServletResponse resp) {


        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) resp;


//        String sessionIdAdmin = request.getHeader("X-cskaoyan-mall-Admin-Token");
//        if (sessionIdAdmin != null && !sessionIdAdmin.equals("")){
//            return sessionIdAdmin;
//        }

        String sessionIdWx = request.getHeader("X-cskaoyan-mall-Admin-Token");
        if (sessionIdWx != null && !sessionIdWx.equals("")) {
            return sessionIdWx;
        }

        return super.getSessionId(request, response);
    }
}
